<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PermissionMgmt.aspx.cs" Inherits="PermissionMgmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <link rel="stylesheet" type="text/css" href="css/StyleSheet.css" />
    <title>Untitled Page</title>
</head>
<body onload="javascript:formInit()">
    <form id="form1" runat="server">
        
    <div>
        <script type="text/javascript">
            
            
            var roleTableCnt = "uiRoleTable";
            
            function formInit()
            {
                var hidActiveRoleTable = document.getElementById("hidActiveRoleTable");
                if(hidActiveRoleTable.value != "")
                {
                    var index = parseInt(hidActiveRoleTable.value, 10);
                    hidActiveRoleTable.value = "";
                    openRoleTable(index);
                }
            }
            
            function openRoleTable(index)
            {
                var hidActiveRoleTable = document.getElementById("hidActiveRoleTable");
                var activeRoleTableIndex = -1;
                if(hidActiveRoleTable.value != "")
                {
                    activeRoleTableIndex = parseInt(hidActiveRoleTable.value, 10);
                }
                 
                if(index != activeRoleTableIndex)
                {
                    if(activeRoleTableIndex >= 0)
                    {
                        document.getElementById(roleTableCnt + hidActiveRoleTable.value).style.display = "none";
                    }
                    document.getElementById(roleTableCnt + index.toString(10)).style.display = "inline";
                    hidActiveRoleTable.value = index.toString(10);
                }
                else
                {
                    document.getElementById(roleTableCnt + index.toString(10)).style.display = "none";
                    hidActiveRoleTable.value = "";
                }
            
            }
        
        
        </script>
        <asp:HiddenField ID="hidSessionId" runat="server" />
        <asp:HiddenField ID="hidActiveRoleTable" runat="server" />
        <table>
            <tr>
                <td>
                    <asp:Button ID="uiSavePermission" runat="server" Text='<%#_rm.GetString(ResKeys.SavePermissionButton) %>' OnClick="uiSavePermission_Click" />
                    <input id="Button1" type="button" value='<%#_rm.GetString(ResKeys.CancelButton) %>' onclick="javascript:window.close()" />
                </td>
            
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblSelectRole" runat="server" Text='<%#_rm.GetString(ResKeys.SelectRole) %>'></asp:Label>
                    <asp:DropDownList ID="uiRoleDropDown" runat="server" Width="530px">
                    </asp:DropDownList>
                    <asp:Button ID="uiAddRole" runat="server" Text='<%#_rm.GetString(ResKeys.AddRoleButton) %>' OnClick="uiAddRole_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="uiErrorMessage" runat="server" Text=""  EnableViewState="false" Visible="false" ForeColor="Red"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    
                    <asp:Repeater ID="uiPermissionList" runat="server">
                        <HeaderTemplate>
                            <table>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td width="400px">
                                    <a href="javascript:openRoleTable(<%#Container.ItemIndex%>)"><%#Eval("Role.RoleName") %></a>
                                </td>
                                <td width="100px">
                                    <asp:CheckBox CssClass="checkBox" ID="uiRemove" runat="server" Text='<%#_rm.GetString(ResKeys.RemoveCheckBox) %>' AutoPostBack="true" OnCheckedChanged="uiRemove_CheckedChanged" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table id='uiRoleTable<%#Container.ItemIndex %>' style="display:none">
                                    <tr>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiCreateRight" Checked='<%#Eval("SecurityItem.Create") %>' runat="server" Text='<%#_rm.GetString(ResKeys.CreateCheckBox) %>' /> 
                                        </td>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiBrowseRight" Checked='<%#Eval("SecurityItem.Browse") %>' runat="server" Text='<%#_rm.GetString(ResKeys.BrowseCheckBox) %>' Enabled='<%#(_sessionData.ItemType == ItemTypeOption.DocumentFolder || _sessionData.ItemType == ItemTypeOption.DocTypeFolder)%>' />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiReadRight" Checked='<%#Eval("SecurityItem.Read") %>' runat="server" Text='<%#_rm.GetString(ResKeys.ReadCheckBox) %>' /> 
                                        </td>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiReadOwnRight" Checked='<%#Eval("SecurityItem.ReadOwn") %>' runat="server" Text='<%#_rm.GetString(ResKeys.ReadOwnCheckBox) %>' /> 
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiUpdateRight" Checked='<%#Eval("SecurityItem.Update") %>' runat="server" Text='<%#_rm.GetString(ResKeys.UpdateCheckBox) %>' /> 
                                        </td>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiUpdateOwnRight" Checked='<%#Eval("SecurityItem.UpdateOwn") %>' runat="server" Text='<%#_rm.GetString(ResKeys.UpdateOwnCheckBox) %>' /> 
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiDeleteRight" Checked='<%#Eval("SecurityItem.Delete") %>' runat="server" Text='<%#_rm.GetString(ResKeys.DeleteCheckBox) %>' /> 
                                        </td>
                                        <td>
                                            <asp:CheckBox CssClass="checkBox" ID="uiDeleteOwnRight" Checked='<%#Eval("SecurityItem.DeleteOwn") %>' runat="server" Text='<%#_rm.GetString(ResKeys.DeleteOwnCheckBox) %>' /> 
                                        </td>
                                    </tr>
                                    
                                    </table>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
